﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bronze.XXT.BLL
{
    class CommonMethod
    {
        public static string FormartStringToDateTime(string strValue) 
        {
            StringBuilder sb = new StringBuilder(strValue);
            if (sb.Length > 4)
                sb.Insert(4, "-");
            if (sb.Length > 7)
                sb.Insert(7, "-");
            if (sb.Length > 10)
                sb.Insert(10, " ");
            if (sb.Length > 13)
                sb.Insert(13, ":");
            if (sb.Length > 16)
                sb.Insert(16, ":");

            return sb.ToString();
        }

        public static DateTime ConvertStringToDateTime(string strValue) 
        {
            strValue = FormartStringToDateTime(strValue);
            return Convert.ToDateTime(strValue);
        }
    }
}
